package file;


import org.junit.jupiter.api.Test;

import java.io.File;
import java.io.IOException;

public class FileCreate {
    //new File(String path+fileName).createNewFile
    @Test
    public void create01(){
        String path = "f:\\重头来过\\创建文件目录\\create01.txt";
        try {
            File file = new File(path);
            file.createNewFile();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    //new File(File parentFile,String fileName).createNewFile
    @Test
    public void create02(){
        //创建文件目录
        File parentFile = new File("f:\\重头来过\\创建文件目录");
        String fileName = "create02.txt";
        File file = new File(parentFile, fileName);
        try {
            file.createNewFile();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    //new file(String parentPath,String fileName).createNewFile
    @Test
    public void create03(){
        String parentPath = "f:\\重头来过\\创建文件目录";
        String fileName = "create03.txt";
        File file = new File(parentPath, fileName);
        try {
            file.createNewFile();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

}
